package reflect;

import reflect.entity.People;
import reflect.entity.User;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class MethonInvokeTest {

    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {

        User user = new User();
        user.setName("luobinjie");


        Object b = user;
        Class<?> c = b.getClass();
        for(Method m : c.getMethods()){
            if(m.getName().equals("SayName")){
                m.invoke(b, "南国勇者102324");
                m.invoke(new People(), "南国勇者102324");
            }
        }
    }
}
